package com.zff.rental.utils.sql.impl;

import com.zff.rental.utils.sql.Condition;
import com.zff.rental.utils.sql.ConditionConnector;

/**
 * @author HCY
 */
class ConditionConnectorImpl extends SqlContextHolder implements ConditionConnector {
    public ConditionConnectorImpl(SqlContext sqlContext) {
        super(sqlContext);
    }

    @Override
    public <T> ConditionConnector and(Condition<T> condition) {
        sqlContext.getSql().append(" AND ").append(condition.toSql());
        return this;
    }

    @Override
    public <T> ConditionConnector and(String condition) {
        // TODO 字符串条件And
        sqlContext.getSql().append(" AND ").append(condition);
        return this;
    }

    @Override
    public <T> ConditionConnector or(Condition<T> condition) {
        sqlContext.getSql().append(" OR ").append(condition.toSql());
        return this;
    }

    @Override
    public <T> ConditionConnector or(String condition) {
        // TODO 字符串条件连接Or
        sqlContext.getSql().append(" OR ").append(condition);
        return this;
    }
}
